<me:UIAM x:Class="WPFExcelReport.TAMSTAMM"
                    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
                    xmlns:ucd="clr-namespace:ReflectionStudio.Controls;assembly=ReflectionStudio.Controls"     
                    xmlns:me="clr-namespace:WPFExcelReport" 
                    xmlns:ex="clr-namespace:WPFExcelReport.Controls;assembly=ExControls"
                    xmlns:T="clr-namespace:WPFExcelReport;assembly=IntexBL"   
                    xmlns:LS="clr-namespace:WPFExcelReport;assembly=TLIEFDAT"   
                    xmlns:DR="clr-namespace:WPFExcelReport;assembly=TDRAUFTR"   
                    xmlns:SD="clr-namespace:WPFExcelReport;assembly=TSDDAT"  
                    xmlns:WH="clr-namespace:WPFExcelReport;assembly=TLAGPL"  
                    xmlns:KS="clr-namespace:WPFExcelReport;assembly=TKSTSTELL"  
                    xmlns:AMD="clr-namespace:WPFExcelReport;assembly=TAMMODUL"           
                    xmlns:AME="clr-namespace:WPFExcelReport;assembly=TAMEINST" 
                    xmlns:AEK="clr-namespace:WPFExcelReport;assembly=TMEKOPF" 
                    xmlns:SR="clr-namespace:WPFExcelReport;assembly=TICC_SRULES" 
                    xmlns:Localization="clr-namespace:Localization;assembly=Localization"
                    xmlns:AE="clr-namespace:WPFExcelReport;assembly=TMEVAR" 
                    x:Name="TV"
                    FontSize="14"
                    Loaded="Window_Loaded"
     >
    <me:UIAM.Resources>
        <CollectionViewSource  x:Key="vwMaster"/>       <CollectionViewSource  x:Key="vwDetail"/>
        <ucd:Divideby10  x:Key="d10"/>
        <ucd:BoolToVisibilityConverter  x:Key="bv"/>
        <ucd:NOTBoolToVisibilityConverter  x:Key="nbv"/>
        <ucd:NOTConverter x:Key="not"/>
        <ucd:Divideby100  x:Key="d100"/>
        <ucd:Divideby1000  x:Key="d1000"/>
        <ucd:SDKEYCONV x:Key="sd"/>
        <ucd:GB2312Convert8859P1  x:Key="gb2312"/>
    </me:UIAM.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"></RowDefinition>
            <RowDefinition Height="1*"></RowDefinition>
            <RowDefinition Height="1*"></RowDefinition>
            <RowDefinition Height="Auto"></RowDefinition> 
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="1*"  />
            <ColumnDefinition Width="1*"/>
        </Grid.ColumnDefinitions>
        <StackPanel Grid.Row="0" Grid.Column="0" Grid.RowSpan="2" >
            
            <WrapPanel Margin="20,10,0,0" >

                <Grid  VerticalAlignment="Top" IsEnabled="{Binding IsCanChg,ElementName=TV}">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"></ColumnDefinition>
                        <ColumnDefinition Width="Auto"></ColumnDefinition>
                    </Grid.ColumnDefinitions>
                    <Button  Click="EditCommand" Width="24" Height="20">
                        <Button.Background>
                            <ImageBrush  ImageSource="/ImagePackage;component/Images/Edit.png" />
                        </Button.Background>
                    </Button>
                </Grid>
                <Grid Margin="10,0,0,0" VerticalAlignment="Top" 
                      IsEnabled="{Binding IsCanDelete,ElementName=TV}">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"></ColumnDefinition>
                        <ColumnDefinition Width="Auto"></ColumnDefinition>
                    </Grid.ColumnDefinitions>
                    <Button Click="DeleteCommand" Height="20" Margin="5,0,0,0" Width="24" >
                        <Button.Background>
                            <ImageBrush  ImageSource="/ImagePackage;component/Images/Remove.png" />
                        </Button.Background>
                    </Button>
                </Grid>

                <Grid Margin="10,0,0,0" VerticalAlignment="Top"  
                      Visibility="{Binding IsEdit,ElementName=TV,Converter={StaticResource bv}}">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"></ColumnDefinition>
                        <ColumnDefinition Width="Auto"></ColumnDefinition>
                    </Grid.ColumnDefinitions>
                    <Button   Click="SaveCommand" Height="20" Margin="5,0,0,0" Width="24" >
                        <Button.Background>
                            <ImageBrush  ImageSource="/ImagePackage;component/Images/Save.png" />
                        </Button.Background>
                    </Button>
                </Grid>

                <TextBlock FontSize="16"  Text="{Binding Source={Localization:Translate Word=设备:}}"/>
                <ex:TXT72 Grid.Column="1" FontSize="16" MaxLength="2"   
                              CharacterCasing="Upper" Text="{Binding KRS,ElementName=TV}" Width="30" />
                <ex:TXT72 Grid.Column="2" FontSize="16" Margin="5,0,0,0" MaxLength="6"  
                              Text="{Binding LFD,ElementName=TV}" KeyUp="Query_KeyUp" Width="60" />
                <ex:TXT72 Grid.Column="2" FontSize="16" Margin="5,0,0,0" MaxLength="6"  
                              Text="{Binding POS,ElementName=TV}" KeyUp="Query_KeyUp" Width="40" />
                <WrapPanel>
                    <SD:K0224 
                            KEY="{Binding AMART,ElementName=TV}"
                          IsEdit="True"  
                          />
                    <SD:K0228 
                            KEY="{Binding AMTYP,ElementName=TV}" 
                          IsEdit="True"  />
                    <KS:TSKS03 Grid.Column="1"  
                                  IsEdit="True"
                                   KEY="{Binding Path=AMKST,ElementName=TV}" />
                </WrapPanel>
                <Button Grid.Column="0"  Click="QueryCommand" Height="20" Margin="5,0,0,0" Width="24" >
                    <Button.Background>
                        <ImageBrush  ImageSource="/ImagePackage;component/Images/Search.png" />
                    </Button.Background>
                </Button>
                <me:TRTLOOM/>
                <WrapPanel>
                    <Button Click="ResetSeq" Content="{Binding Source={Localization:Translate Word=重置序列号}}"
                    Visibility="{Binding IsITX,Converter={StaticResource bv}}"/>
                    <Grid Margin="10,0,0,0" VerticalAlignment="Top"  Visibility="Collapsed" >
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"></ColumnDefinition>
                            <ColumnDefinition Width="Auto"></ColumnDefinition>
                        </Grid.ColumnDefinitions>
                        <DR:TDRAUFTR  Grid.Column="0" Name="cDR" DocType="{Binding PRTYPE,ElementName=TV}" PrintType="OpenExcel" />
                        <Button  Grid.Column="1"   Click="btnPrint_Click" Height="20" Margin="5,0,0,0" Width="Auto" Content="{Binding Source={Localization:Translate Word=打印}}" />
                    </Grid>
                </WrapPanel>
            </WrapPanel>
            <StackPanel>
                <WrapPanel  Margin="20,10,0,0">
                    <Grid Margin="10,0,0,0"  VerticalAlignment="Top" >
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"></ColumnDefinition>
                            <ColumnDefinition Width="Auto"></ColumnDefinition>
                        </Grid.ColumnDefinitions>
                        <Button Grid.Column="0"  Click="NewCommand" Height="20" Margin="5,0,0,0" Width="24"
                            IsEnabled="{Binding IsCanNew,ElementName=TV}"  >
                            <Button.Background>
                                <ImageBrush  ImageSource="/ImagePackage;component/Images/Add.png" />
                            </Button.Background>
                        </Button>
                    </Grid>
                    <WrapPanel>
                        <SD:K0224 
                            KEY="{Binding AMART,ElementName=TV}"
                          IsEdit="True"
                          />
                        <SD:K0228 
                            KEY="{Binding AMTYP,ElementName=TV}" 
                           IsEdit="True"
                            />
                        <KS:TSKS03 Grid.Column="1"  
                                    IsEdit="True"
                                   KEY="{Binding Path=AMKST,ElementName=TV}" />
                    </WrapPanel>
                </WrapPanel>
                <WrapPanel Visibility="{Binding IsNew,ElementName=TV,Converter={StaticResource bv}}"  Margin="20,10,0,0">
                    <TextBlock Text="{Binding Source={Localization:Translate Word=设备编号:}}"  Margin="20,0,0,20" />
                    <ex:TXT72 Text="{Binding KRS,ElementName=TV}" CharacterCasing="Upper" MaxLength="2" PRE="  " Width="40"  Margin="20,0,0,0" />
                    <ex:TXT72 Text="{Binding LFD,ElementName=TV}" MaxLength="4" PRE="0000" Width="60"  Margin="20,0,0,0"/>
                    <ex:TXT72 Text="{Binding POS,ElementName=TV}" MaxLength="2" PRE="00" Width="40"  Margin="20,0,0,0"/>
                    <CheckBox Content="{Binding Source={Localization:Translate Word=多中位:}}" Name="IsMM"  Margin="20,0,0,0"/>
                    <ex:NumericBox Text="{Binding MLFD,ElementName=TV}" DecimalPlaces="0" Width="60"
                                    Margin="20,0,0,0"
                                   IsEnabled="{Binding IsChecked,ElementName=IsMM}" />
                    <CheckBox Content="{Binding Source={Localization:Translate Word=多末位:}}" Name="IsMP"  Margin="20,0,0,0" 
                              IsChecked="{Binding IsChecked,ElementName=IsMM,Converter={StaticResource not}}"/>
                    <ex:NumericBox Text="{Binding MPOS,ElementName=TV}" DecimalPlaces="0"  Width="60"
                                    Margin="20,0,0,0"
                                   IsEnabled="{Binding IsChecked,ElementName=IsMP}" />
                    <Button Grid.Column="0"  Click="NewCommand" Height="20" Margin="20,0,0,0" Width="24" >
                        <Button.Background>
                            <ImageBrush  ImageSource="/ImagePackage;component/Images/button_ok.png" />
                        </Button.Background>
                    </Button>
                </WrapPanel>
            </StackPanel>
            <StackPanel Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2"  >
                <WrapPanel  Margin="20,10,0,0">
                    <TextBlock Text="{Binding Source={Localization:Translate Word=设备编号:}}"/>
                    <TextBlock Text="{Binding AMNRKRS}" Width="24" />
                    <TextBlock Text="{Binding AMLFDNR}" Width="48"   />
                    <TextBlock Text="{Binding AMPOS}" Width="36" />
                    <TextBlock Text="{Binding Source={Localization:Translate Word=说明:}}"/>
                    <ex:TXT72 Text="{Binding AMBEZ,Converter={StaticResource gb2312}}"  
                              IsReadOnly="{Binding IsEdit,Converter={StaticResource not}, ElementName=TV}" Width="100" />
                </WrapPanel>
                <WrapPanel  Margin="20,10,0,0">
                    <TextBlock Text="{Binding Source={Localization:Translate Word=短号:}}"/>
                    <ex:TXT72 MaxLength="8" Text="{Binding AMBDEMA}" 
                              IsReadOnly="{Binding IsEdit,Converter={StaticResource not}, ElementName=TV}" Width="40" />
                    <TextBlock Text="{Binding Source={Localization:Translate Word=分组:}}"/>
                    <ex:TXT72 Text="{Binding AMHERST}" IsReadOnly="{Binding IsEdit,Converter={StaticResource not}}" MaxLength="20"/>

                    <CheckBox Content="{Binding Source={Localization:Translate Word=标准:}}" IsChecked="{Binding IsSTD,ElementName=TV}"/>


                    <WrapPanel>
                        <TextBlock   Text="{Binding Source={Localization:Translate Word=库位:}}"/>
                        <ex:TXT72  MaxLength="2" CharacterCasing="Upper"  Text="{Binding AMLO}"  
                                   IsReadOnly="{Binding IsEdit,Converter={StaticResource not}, ElementName=TV}" Width="30"/>
                        <ex:TXT72  MaxLength="2" CharacterCasing="Upper"  Text="{Binding AMLB}"  
                                   IsReadOnly="{Binding IsEdit,Converter={StaticResource not}, ElementName=TV}" Width="30"/>
                        <ex:TXT72  MaxLength="8" CharacterCasing="Upper"  Text="{Binding AMLPLATZ}"  
                                   IsReadOnly="{Binding IsEdit,Converter={StaticResource not}, ElementName=TV}" Width="60"/>
                        <CheckBox  Grid.Column="1" Name="cWH"></CheckBox>
                        <WH:TSWH  KEY="{Binding WH,ElementName=TV}" 
                                  Visibility="{Binding IsChecked,ElementName=cWH,Converter={StaticResource bv}}"/>
                    </WrapPanel>  
                </WrapPanel>
                <WrapPanel Margin="20,10,0,0">
                    <TextBlock Text="{Binding Source={Localization:Translate Word=对应打印机:}}"/>
                    <ex:TXT72 Text="{Binding AMFILLER}" Width="200" MaxLength="72"
                               IsReadOnly="{Binding IsEdit,Converter={StaticResource not}, ElementName=TV}"/>
                </WrapPanel>
                <WrapPanel Margin="20,10,0,0">
                    <LS:TSLS02 Grid.Column="1"  
                                 IsEdit="{Binding IsEdit,ElementName=TV}"
                                   KEY="{Binding Path=LIEFNR,ElementName=TV}"
                                  ORDERNUM="{Binding Path=LIEFNR,ElementName=TV}"
                                    />
                    <SD:K8881 Grid.Column="1"  
                                  IsEdit="{Binding IsEdit,ElementName=TV}"
                                   KEY="{Binding Path=AMCD,ElementName=TV}"
                                 ORDERNUM="{Binding Path=AMCD,ElementName=TV}"
                                   Width="Auto" />
                    <SD:K0224 KEY="{Binding AMART,ElementName=TV}"
                          IsEdit="{Binding IsEdit,ElementName=TV}"
                          ORDERNUM="{Binding AMART,ElementName=TV}"
                          />
                    <SD:K0228 KEY="{Binding AMTYP,ElementName=TV}"
                          IsEdit="{Binding IsEdit,ElementName=TV}"
                          ORDERNUM="{Binding AMTYP,ElementName=TV}"
                          />
                    <KS:TSKS03 Grid.Column="1" 
                                  IsEdit="True"
                                   KEY="{Binding Path=AMKST,ElementName=TV}"
                            ORDERNUM="{Binding Path=AMKST,ElementName=TV}"
                                   Width="Auto" />

                </WrapPanel>
            </StackPanel> 
        </StackPanel>
        <DataGrid  Grid.Row="0"  Grid.Column="1" Grid.RowSpan="2"
                   Margin="20,20,0,0"
                   VerticalAlignment="Top"  
                   AutoGenerateColumns="False"
                   EnableRowVirtualization="False"
                   IsReadOnly="True"
                   VerticalScrollBarVisibility="Auto"
                   HorizontalScrollBarVisibility="Auto"
                   HeadersVisibility="Column"     
                   ItemsSource="{Binding Source={StaticResource ResourceKey=vwMaster}}" 
                   IsSynchronizedWithCurrentItem="True" 
                   x:Name="dlgMaster"  
                   RowDetailsVisibilityMode="Visible"  
                    >
            <DataGrid.Columns>
                <!--DataGridTemplateColumn Header="{Binding Source={Localization:Translate Word=监控}}">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate >
                            <Grid >
                                <me:TMON/>
                            </Grid>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn-->
                <DataGridTextColumn  Binding="{Binding AMSTDVAR}" Header="{Binding Source={Localization:Translate Word=标准}}" />
                <DataGridTextColumn Binding="{Binding Path=AMART,Converter={StaticResource sd},ConverterParameter=0224}" Header="{Binding Source={Localization:Translate Word=类型}}" Width="Auto"  />
                <DataGridTextColumn Binding="{Binding Path=AMTYP,Converter={StaticResource sd},ConverterParameter=0228}" Header="{Binding Source={Localization:Translate Word=型号}}" Width="Auto"  />
                <DataGridTextColumn Binding="{Binding Path=AMBDEMA}" Header="{Binding Source={Localization:Translate Word=BDE}}" Width="40"  />
                <DataGridTextColumn  Binding="{Binding AMNRKRS}"  />
                <DataGridTextColumn Binding="{Binding Path=AMLFDNR}" Header="{Binding Source={Localization:Translate Word=设备}}" Width="Auto"  />
                <DataGridTextColumn Binding="{Binding AMPOS}" Width="Auto"/>
                <DataGridTextColumn  Binding="{Binding AMBEZ,Converter={StaticResource gb2312}}" Header="{Binding Source={Localization:Translate Word=说明}}" Width="60"/>
                <DataGridTextColumn Binding="{Binding Path=AMHERST}" Header="{Binding Source={Localization:Translate Word=制造商}}" Width="30"  />
                <DataGridTextColumn Binding="{Binding Path=AMKSTKRS}"  Width="20"  />
                <DataGridTextColumn Binding="{Binding Path=AMKST}"  Width="40"  />
                <DataGridTextColumn Binding="{Binding Path=AMLO}" Header="{Binding Source={Localization:Translate Word=LO}}" Width="20"  />
                <DataGridTextColumn Binding="{Binding Path=AMLB}" Header="{Binding Source={Localization:Translate Word=LB}}" Width="20"  />
                <DataGridTextColumn Binding="{Binding Path=AMLPLATZ}" Header="{Binding Source={Localization:Translate Word=LP}}" Width="40"  />
                <DataGridTextColumn Binding="{Binding Path=AMFILLER}" Header="{Binding Source={Localization:Translate Word=其他}}" Width="100"  />
            </DataGrid.Columns>
        </DataGrid  >
        <TabControl Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2">
            <TabItem Header="{Binding Source={Localization:Translate Word=参数}}">
                <Grid >
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="1*"/>
                        <ColumnDefinition Width="1*"/>
                    </Grid.ColumnDefinitions>
                    <AMD:TAMMODUL  Grid.Column="0"   Name="cAM05"
                                       IsAuto="True"
                                       EXAUF="{Binding KEY,ElementName=TV}"/>
                    <AME:TAMEINST   Grid.Column="1"   Name="cAM06"
                                         EXAUF="{Binding KEY,ElementName=cAM05}" />
                </Grid>
            </TabItem>
            <TabItem Header="{Binding Source={Localization:Translate Word=工艺组合}}">
                <AEK:TMEKOPF Grid.Row="0"    
                                Name="cAE"  
                                EXAUF="{Binding KEY,ElementName=TV}" />
            </TabItem>
            <TabItem Header="{Binding Source={Localization:Translate Word=排产规则}}">
                <SR:TICC_SRULES EXAUF="{Binding KEY,ElementName=TV}"/>
            </TabItem> 
            <TabItem Header="{Binding Source={Localization:Translate Word=运行监控}}">
                <ListBox    ItemsSource="{Binding Source={StaticResource ResourceKey=vwMaster}}"  
                                ScrollViewer.CanContentScroll="True">
                    <ListBox.ItemsPanel>
                        <ItemsPanelTemplate>
                            <WrapPanel  MaxWidth="800"/>
                        </ItemsPanelTemplate>
                    </ListBox.ItemsPanel>
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <Grid Width="100">
                                <Grid.RowDefinitions>
                                    <RowDefinition/>
                                    <RowDefinition/>
                                </Grid.RowDefinitions>
                                <TextBlock Grid.Row="0" Text="{Binding Path=AMBDEMA}"/>
                                <me:TMON Grid.Row="1"/>
                            </Grid>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>
            </TabItem>
           
            <TabItem Header="{Binding Source={Localization:Translate Word=维修保养}}">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="1*"/>
                    </Grid.RowDefinitions>
                    <ListBox    ItemsSource="{Binding Source={StaticResource ResourceKey=vwMaster}}"  
                                ScrollViewer.CanContentScroll="True">
                        <ListBox.ItemsPanel>
                            <ItemsPanelTemplate>
                                <WrapPanel  MaxWidth="800"/>
                            </ItemsPanelTemplate>
                        </ListBox.ItemsPanel>
                        <ListBox.ItemTemplate>
                            <DataTemplate>
                                <Grid>
                                    <Grid.RowDefinitions>
                                        <RowDefinition/>
                                        <RowDefinition/>
                                    </Grid.RowDefinitions>
                                    <TextBlock Text="{Binding Path=AMBDEMA}"/>

                                </Grid>
                            </DataTemplate>
                        </ListBox.ItemTemplate>
                    </ListBox>
                </Grid>

            </TabItem>
            <TabItem Header="{Binding Source={Localization:Translate Word=专件管理}}"></TabItem>
            <TabItem Header="{Binding Source={Localization:Translate Word=能源管理}}"></TabItem>
            <TabItem Header="{Binding Source={Localization:Translate Word=配件管理}}"></TabItem>
        </TabControl>
     
    </Grid>
</me:UIAM>
